package org.example.service.impl;

import org.example.entity.Access;
import org.example.mapper.AccessMapper;
import org.example.service.IAccessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2023-05-07
 */
@Service
public class AccessServiceImpl extends ServiceImpl<AccessMapper, Access> implements IAccessService {

    @Cacheable(cacheNames = "s59",key = "'AccessServiceImpl.getById.' + #id")
    @Override
    public Access getById(Serializable id) {
        System.out.println("id="+id);
        return super.getById(id);
    }

    @CacheEvict(cacheNames = "s59",key = "'AccessServiceImpl.getById.' + #id")
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

    @CachePut(cacheNames = "s59",key = "'AccessServiceImpl.getById.' + #access.id")
    public Access updateByIdwithCache(Access access){
        super.updateById(access);
        return access;
    }

    @CachePut(cacheNames = "s59",key = "'AccessServiceImpl.getById.' + #access.id")
    @Override
    public Access saveWithCache(Access access) {
        super.save(access);
        return access;
    }
}
